import 'package:flutter_frame/app/core/core.dart';
import 'package:flutter_frame/app/core/utils/log_util.dart';
import 'package:flutter_frame/app/modules/home/profile/view.dart';
import 'package:sensors_plus/sensors_plus.dart';

class HomeController extends GetxController {
  int index = 0;

  // 是否隐藏底部导航栏
  bool isHideBottomNavigationBar = false;

  final myTabs = <Widget>[
    // WebViewPageWidget(),
    const ProfilePage(),
    Container(),
  ];

  // tab切换
  void changeTab(int i) {
    index = i;
    update();
  }

  // 拦截返回键
  Future<bool> onWillPop() async {
    if (isHideBottomNavigationBar) {
      isHideBottomNavigationBar = false;
      update();
      return false;
    } else {
      return true;
    }
  }

  // 传感器测试
  void sensorTest() {
    final accelerometer = accelerometerEventStream();
    accelerometer.listen((event) {
      AppLogger.log('加速度事件流:${event.x}-${event.y}-${event.z}');
    });
  }
}
